
<label class="btn-select hidden">
<select style="visibility:hidden; width:0; height:0" id="<?php echo $id;?>" name="<?php echo $name;?>" data-value="<?php echo $value?>">
<?php


$param['options'] = isset($param['options']) ? (is_array($param['options']) ? $param['options'] : explode(PHP_EOL, $param['options'])) : [];

foreach($param['options'] as $k=>$v){
	$selected = $v['key'] == $value ? ' selected' : '';
?>
<option value="<?php echo $v['key']?>"<?php echo $selected?>><?php echo $v['value']?></option>
<?php
}
?>
</select>
</label>
<textarea name="<?php echo $name;?>" id="<?php echo $id;?>" class="hidden"></textarea>
<table cellpadding="2" cellspacing="1" id="<?php echo $id;?>-radio-table">
<?php
$value = $value ? json_decode($value, true) : [['key'=>'', 'value'=>'']];
if ($value) foreach($value as $k=>$v){?>
	<tr index="<?php echo $k?>"> 
      <td width="30" align="right">KEY：</td>
      <td width="110"><textarea name="<?php echo $name;?>_[<?php echo $k?>][key]" id="options" class="textarea-text" style="height:20px;width:80px;resize:none; margin:5px 0"><?php echo $v['key']?></textarea></td>
      <td width="230">VALUE：<textarea name="<?php echo $name;?>_[<?php echo $k?>][value]" id="options" class="textarea-text" style="height:20px;width:150px;resize:none;"><?php echo $v['value']?></textarea></td>
      <td align="left"><a href="javascript:;" style="color:rgba(0,102,255,1)" class="addoptions">添加</a> <a href="javascript:;" style="color:rgba(0,102,255,1)" class="deloptions<?php echo $k==0 ? ' hidden' : ''?>">删除</a></td>
    </tr>
<?php
}
?>
</table>
<SCRIPT LANGUAGE="JavaScript">
<!--


$(function(){
	function $<?php echo $id;?>_change(){
		
	}
	
	$('.addoptions', '#<?php echo $id;?>-radio-table').live('click',function(){
		var index = parseInt($('#<?php echo $id;?>-radio-table tr:last').attr('index')) + 1;
		var tr = $('#<?php echo $id;?>-radio-table tr:first').clone();
		//alert(index)
		tr.attr('index', index);
		tr.find('textarea:first').attr('name', '<?php echo $name;?>_['+index+'][key]').val('');
		tr.find('textarea:last').attr('name', '<?php echo $name;?>_['+index+'][value]').val('');
		tr.find('.deloptions').removeClass('hidden');
		tr.appendTo($('#<?php echo $id;?>-radio-table'));
	});
	$('.deloptions', '#<?php echo $id;?>-radio-table').live('click',function(){
		if($('#<?php echo $id;?>-radio-table tr').length >1){
			$(this).parent().parent().remove();
		}
	});
	$('textarea', '#<?php echo $id;?>-radio-table').bind('change input paste',function(){
		//$(this).next('.num').text($(this).attr("value").length);
	});
});
//-->
</SCRIPT>